package com.example.job;

import com.example.service.TrafficService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author yinxin
 * @version 1.0
 * @Description:
 * @date 2022/6/2410:29
 */
@Component
@Slf4j
public class TrafficJobHandler {

    @Autowired
    TrafficService trafficService;

    @XxlJob(value = "trafficJobHandler",init = "init",destroy = "destroy")
    public ReturnT<String> execute(String param){
        log.info("任务方法执行中，触发成功!参数:{}",param);
        trafficService.deleteExpireTraffic();
        log.info("任务方法执行结束!");
        return ReturnT.SUCCESS;
    }

    private void init(){
        log.info("MyJobHandler init>>>>>");
    }

    private void destroy(){
        log.info("MyJobHandler destroy>>>>>");
    }

}
